package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;

/**
 * 商品类
 */
@Setter
@Getter
public class Commodity extends BaseDomain {
    public static final int STATUS_NORMAL=1;//正常
    public static final int STATUS_NEW=2;//新款
    public static final int STATUS_FASHION=3;//流行
    public static final int STATUS_HOT=4;//热门

    public static final int TYPE_NORMAL=1;//旅游特色衣物
    public static final int TYPE_HOT=2;//旅游网红打卡食品
    public static final int TYPE_FIRST=3;//旅游必买小挂饰

    private String name;//名字

    private String title;//标题

    private String picture;//图片

    private String color;//颜色

    private Double size;//尺寸

    private  Integer price;//价格

    private Integer discountPrice;//打折价格

    private Integer status=STATUS_NORMAL;//状态

    private Integer type=TYPE_NORMAL;//类型

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8")
    private Date createTime;//创建时间

    public String getStatueName(){
        if (status==STATUS_NORMAL){
            return "正常";
        }else if (status==STATUS_NEW){
            return "新款";
        }else if (status==STATUS_FASHION){
            return "流行";
        }else if (status==STATUS_HOT){
            return "热门";
        }
        return "";
    }
    public String getTypeName(){
        if (type==TYPE_NORMAL){
            return "旅游特色衣物";
        }else if (type==TYPE_HOT){
            return "旅游网红食品";
        }else if (type==TYPE_FIRST){
            return "旅游小挂饰";
        }
        return "";
    }
    public String getJson(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("title",title);
        map.put("picture",picture);
        map.put("color",color);
        map.put("size",size);
        map.put("price",price);
        map.put("discountPrice",discountPrice);
        map.put("status",status);
        map.put("type",type);
        return JSONUtils.toJSONString(map);
    }


}